//////////////////////////////////////////////////////////////////////////
//
// This file is a part of UKROP project.
// Copyright (c) Vladimir Gumenuk, 2008-2014.
//
// PROJECT:         Xort compiler
// FILE:            System.cpp - native object support (example)
// AUTHOR:          Vladimir Gumenuk
// DATE:            4-Sep-2014
//
//////////////////////////////////////////////////////////////////////////


#include "stdafx.h"
#include "System.h"
#include "WinFile.h"
#include "AlertObject.h"

CSystem::CSystem()
{
    m_dwRefCount = 0;
}

CSystem::~CSystem()
{
}

//////////////////////////////////////////////////////////////////////////
// This is an example how to create and return other native objects:
// WinFile CreateWinFile();
// AlertObject CreateAlertObject();

int CSystem::Invoke( lpcstr lpszName, XNIVariantArray *pArgs, XNIVariant& vResultOut )
{
    if( !lpszName )
        return FALSE;

    int iRet = 0;
    XortNativeInterface *pObj = NULL;

    if( strcmp( lpszName, "CreateWinFile" ) == 0 )
    {
        pObj = new CWinFile();
    }
    else if( strcmp( lpszName, "CreateAlertObject" ) == 0 )
    {
        pObj = new CAlertObject();
    }

    if( pObj )
    {
        pObj->AddRef();

        vResultOut.bType = xni_ptr;
        vResultOut.dwSize = 0;
        vResultOut._p = pObj;

        iRet = XOK;
    }

    return iRet;
}